//
//  UILabelAlignmentViewController.m
//  iOS UI Sample Code
//
//  Created by 규성 이 on 12. 2. 19..
//  Copyright (c) 2012년 kkamci77@gmail.com. All rights reserved.
//

#import "UILabelAlignmentViewController.h"

@implementation UILabelAlignmentViewController

@synthesize lblFirst, lblSecond, lblThird;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self.navigationItem setTitle:@"Alignment"];
    
    [self.lblFirst setBackgroundColor: UIColor.blackColor]; 
    [self.lblFirst setTextColor:UIColor.whiteColor];
    [self.lblFirst setTextAlignment:UITextAlignmentLeft];
//    [self.lblFirst sizeToFit];
    
    [self.lblSecond setBackgroundColor: UIColor.redColor];
    [self.lblSecond setTextAlignment:UITextAlignmentCenter];
//    [self.lblSecond sizeToFit];
    
    [self.lblThird setBackgroundColor: UIColor.blueColor];
    [self.lblThird setTextAlignment:UITextAlignmentRight];
//    [self.lblThird sizeToFit];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)dealloc {
    [lblFirst release];
    [lblSecond release];
    [lblThird release];
    
    [super dealloc];
}

#pragma Button Action
- (IBAction)sizeToFitAction:(id)sender
{
//    [self.lblFirst sizeToFit];
//    [self.lblSecond sizeToFit];
//    [self.lblThird sizeToFit];
//    [self.view bringSubviewToFront:self.lblFirst];
    [self.view insertSubview:self.lblFirst atIndex:1];
    int ind = [[self.view subviews] indexOfObject:self.lblFirst];
    NSLog(@"%d", ind);
    
//    self.view subviews
}

- (IBAction)originalSizeAction:(id)sender
{
    
    [self.lblFirst setHidden:YES];
//    [self.lblFirst setFrame:CGRectMake(0.0f, 0.0f, 320.0f, 100.0f)];
//    [self.lblSecond setFrame:CGRectMake(0.0f, 100.0f, 320.0f, 100.0f)];
//    [self.lblThird setFrame:CGRectMake(0.0f, 200.0f, 320.0f, 100.0f)];
//    
//    UIActionSheet * sheet = [[[UIActionSheet alloc] init] autorelease];
//    sheet.delegate = self;
//    [sheet addButtonWithTitle:@"Delete"];
//    [sheet addButtonWithTitle:@"Cancel"];
//    sheet.destructiveButtonIndex = 1;
////    [sheet setAlpha:0.5f];
//    [sheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];
//    [sheet setBackgroundColor:[UIColor redColor]];
//    
////    sheet.cancelButtonIndex = 1;
//    [sheet showFromToolbar:self.navigationController.toolbar];
}
@end
